package com.situ.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.web.entity.Student;
import com.situ.web.service.IStudentService;
import com.situ.web.service.impl.StudentServiceImpl;

public class FindAllStudentServlet extends HttpServlet{
	private IStudentService studentService = new StudentServiceImpl();

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
//		req.setCharacterEncoding("utf-8");
//		resp.setContentType("text/html;charset=utf-8");
//		req.setCharacterEncoding("utf-8");
//		resp.setContentType("text/html;charset=utf-8");
//		req.setCharacterEncoding("utf-8");
//		resp.setContentType("text/html;charset=utf-8");
//		req.setCharacterEncoding("utf-8");
//		resp.setContentType("text/html;charset=utf-8");
//		req.setCharacterEncoding("utf-8");
//		resp.setContentType("text/html;charset=utf-8");
		//1.接收请求参数，封装成对象
		//2.调用业务层进行处理
		List<Student> list = studentService.findAll();
		//3.将处理结果返回给浏览器
		//乱码问题
		//将list学生集合数据放到req中
		req.setAttribute("list", list);
		//转发到jsp页面进行展示
		req.getRequestDispatcher("/student_list.jsp").forward(req, resp);
	}
}
